#!/usr/bin/env python
#
#       ToServer.py
#       
#       Copyright 2009 Ben Davis <its.hip@gmail.com>
#       
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#       GNU General Public License for more details.
#       
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

from Client import Client
client = Client()

class Packet:
    """Base-class for packets. Simply put in the info you need to send
    and create a matching class in the Server Incoming.py which acts upon
    the data on a __call__"""
    def __init__(self):
        pass

class EndTurn(Packet):
    """Ends the client's player's turn"""
    pass

class Fire(Packet):
    """Fires a ship's weapon"""
    def __init__(self, ship, weapon):
        # weapon 0 == a, weapon 1 == b
        self.ship = ship.key()
        self.weapon = weapon

class Move(Packet):
    """Created when the client requests a ship to move.
    
    'path' should be a list of (x, y) tuples"""
    def __init__(self, ship, path):
        self.ship = ship.key()
        self.path = path

class Rotate(Packet):
    """Created when the client requests a ship to rotate on the spot.
    
    'r' should be the requested new rotation"""
    def __init__(self, ship, r):
        self.ship = ship.key()
        self.r = r

class Say(Packet):
    """Created when local player says something"""
    def __init__(self, text):
        self.text = text

class ChoosePlayer(Packet):
    """Choosing a player to be."""
    def __init__(self, choice):
        self.choice = choice